<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">xml表</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">xml名字：</text></view>
                  <input  placeholder="请输入xml名字" v-model="model.xmlName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">xml类型：</text></view>
                  <input  placeholder="请输入xml类型" v-model="model.xmlType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否启用 ：</text></view>
                  <input  placeholder="请输入是否启用 " v-model="model.delFlag"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">设备名称：</text></view>
                  <input  placeholder="请输入设备名称" v-model="model.equipmentname"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">分系统名称：</text></view>
                  <input  placeholder="请输入分系统名称" v-model="model.subsystemname"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">设备代号：</text></view>
                  <input  placeholder="请输入设备代号" v-model="model.equipmentcode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">数据采集频率：</text></view>
                  <input  placeholder="请输入数据采集频率" v-model="model.grabf"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">图像合并数据数量：</text></view>
                  <input  placeholder="请输入图像合并数据数量" v-model="model.maxPacketNum"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">复帧配置：</text></view>
                  <input  placeholder="请输入复帧配置" v-model="model.kafkaTableName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">图像帧解析方案，1无容器，2高微柜：</text></view>
                  <input  placeholder="请输入图像帧解析方案，1无容器，2高微柜" v-model="model.imageParseMethod"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">图像数据库的长度：</text></view>
                  <input  placeholder="请输入图像数据库的长度" v-model="model.imageDataLen"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">devicename：</text></view>
                  <input  placeholder="请输入devicename" v-model="model.deviceName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">二级索引的segment：</text></view>
                  <input  placeholder="请输入二级索引的segment" v-model="model.secondSegment"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">数据segment：</text></view>
                  <input  placeholder="请输入数据segment" v-model="model.dataSegment"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">图像segment：</text></view>
                  <input  placeholder="请输入图像segment" v-model="model.imgSegment"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">包名称：</text></view>
                  <input  placeholder="请输入包名称" v-model="model.packageName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">舱段或飞行器标识（产生舱段）：</text></view>
                  <input  placeholder="请输入舱段或飞行器标识（产生舱段）" v-model="model.sc"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件标志：</text></view>
                  <input  placeholder="请输入文件标志" v-model="model.dty"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件名的apid：</text></view>
                  <input  placeholder="请输入文件名的apid" v-model="model.apid"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件名的ssid：</text></view>
                  <input  placeholder="请输入文件名的ssid" v-model="model.ssid"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">文件名的ssty：</text></view>
                  <input  placeholder="请输入文件名的ssty" v-model="model.sdty"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "GdqvXmlForm",
        components:{myDate},
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/test/gdqvXml/queryById",
                  add: "/test/gdqvXml/add",
                  edit: "/test/gdqvXml/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
